package ru.linnenson.darshana.infrastructure.persistence.models;

import com.vladmihalcea.hibernate.type.array.ListArrayType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.util.List;

@Data
@Entity
@ToString(callSuper = true)
@Table(name = "math_task")
@NoArgsConstructor
@AllArgsConstructor
@TypeDef(name = "list-array", typeClass = ListArrayType.class)
public class MathTaskStore {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  Integer id;

  String text;

  @Type(type = "list-array")
  @Column(columnDefinition = "varchar[]")
  List<String> tags;

  @Type(type = "list-array")
  @Column(name = "photo_ids", columnDefinition = "varchar[]")
  List<String> photoIds;

  @Type(type = "list-array")
  @Column(name = "solution_photo_ids", columnDefinition = "varchar[]")
  List<String> solutionPhotoIds;

  @ManyToOne
  @JoinColumn(name = "theme_id")
  ThemeStore theme;

  @ManyToOne
  @JoinColumn(name = "source_id")
  SourceStore source;

  @ManyToOne
  @JoinColumn(name = "number_in_kim_id")
  NumberInKimStore numberInKim;
}
